package com.ruoyi.count.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.student.api.RemoteStudentService;
import com.ruoyi.student.api.domain.SysStudent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.count.domain.SysStudentWork;
import com.ruoyi.count.service.ISysStudentWorkService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 工作Controller
 * 
 * @author ruoyi
 * @date 2024-03-26
 */
@RestController
@RequestMapping("/count")
public class SysStudentWorkController extends BaseController
{
    @Autowired
    private ISysStudentWorkService sysStudentWorkService;
    @Autowired
    private RemoteStudentService remoteStudentService;


    /**
     * 根据时间分组数据
     */
    @Log(title = "工作", businessType = BusinessType.INSERT)
    @PostMapping("/groupByTime")
    public List<Integer> groupByTime()
    {
        return sysStudentWorkService.groupByTime();
    }


    /**
     * 修改学生的状态
     */

    @Log(title = "工作", businessType = BusinessType.INSERT)
    @GetMapping("/updateStatusClass/{studentId}")
    public void updateStatusClass(@PathVariable Long studentId)
    {
        remoteStudentService.changeStatusById(studentId);
    }


    /**
     * 学生是未就业的
     */
    @GetMapping ("/stundetListstatus")
    public TableDataInfo listStudentStatus(SysStudent sysStudent)
    {
            startPage();
        TableDataInfo tableDataInfo = remoteStudentService.unemployedStudentList();
            return tableDataInfo;
    }

    /**
     * 查询工作列表
     */
    @RequiresPermissions("employment:count:list")
    @GetMapping("/list")
    public TableDataInfo list(SysStudentWork sysStudentWork)
    {
        startPage();
        List<SysStudentWork> list = sysStudentWorkService.selectSysStudentWorkList(sysStudentWork);
        return getDataTable(list);
    }

    /**
     * 导出工作列表
     */
    @RequiresPermissions("employment:count:export")
    @Log(title = "工作", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysStudentWork sysStudentWork)
    {
        List<SysStudentWork> list = sysStudentWorkService.selectSysStudentWorkList(sysStudentWork);
        ExcelUtil<SysStudentWork> util = new ExcelUtil<SysStudentWork>(SysStudentWork.class);
        util.exportExcel(response, list, "工作数据");
    }

    /**
     * 获取工作详细信息
     */
    @RequiresPermissions("employment:count:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysStudentWorkService.selectSysStudentWorkById(id));
    }

    /**
     * 新增工作
     */
    @RequiresPermissions("employment:count:add")
    @Log(title = "工作", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysStudentWork sysStudentWork)
    {
        return toAjax(sysStudentWorkService.insertSysStudentWork(sysStudentWork));
    }

    /**
     * 修改工作
     */
    @RequiresPermissions("employment:count:edit")
    @Log(title = "工作", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysStudentWork sysStudentWork)
    {
        return toAjax(sysStudentWorkService.updateSysStudentWork(sysStudentWork));
    }

    /**
     * 删除工作
     */
    @RequiresPermissions("employment:count:remove")
    @Log(title = "工作", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysStudentWorkService.deleteSysStudentWorkByIds(ids));
    }
}
